#define _CRT_SECURE_NO_WARNINGS
#pragma warning(disable:6031)
#include<stdio.h>
void ShellSort(int* a,int size)
{
	int gap = size;
	while (gap > 1)
	{
		gap = (gap / 3) + 1;
		for (int i = 0; i <size-gap;i++ )
		{
			int end = i;
			int temp = a[end + gap];
			while (end >= 0)
			{
				if (a[end] > temp)
				{
					a[end + gap] = a[end];
					end-=gap;
				}
				else
				{
					break;
				}
			}
			a[end + gap] = temp;
		}
	}
}

int main()
{
	int arr[] = { 2,7,4,5,8,1 };
	int size = sizeof(arr) / sizeof(int);
	ShellSort(arr, size);
	for (int i = 0; i < size; i++)
	{
		printf("%d ", arr[i]);
	}
	return 0;
}